package model.entity;

import model.map.MapPoint;

public class Attack extends AIBehavior {
	
	private Entity attackTarget;

	public Attack(Entity attackTarget) {
		this.attackTarget=attackTarget;
	}

	@Override
	public void update(Entity e) {
		MapPoint enemyLocation=attackTarget.getDirection();
		MapPoint currentLocation=e.getDirection();
		
		MapPoint attackDirection=MapPoint.subtractPoints(enemyLocation, currentLocation); ;
		
		
		if (MapPoint.findDistance(enemyLocation, currentLocation)==1){
			e.useDefaultAttack();

		}
		
		else {
			if (attackDirection.equals(MapPoint.NORTH)){
				e.commandMoveNorth();
			}
			else if(attackDirection.equals(MapPoint.SOUTH)){
				e.commandMoveSouth();
			}
			else if(attackDirection.equals(MapPoint.NORTHEAST)){
				e.commandMoveNE();
			}
			else if(attackDirection.equals(MapPoint.NORTHWEST)){
				e.commandMoveNW();
			}
			else if(attackDirection.equals(MapPoint.SOUTHEAST)){
				e.commandMoveSE();
			}
			else if(attackDirection.equals(MapPoint.SOUTHWEST)){
				e.commandMoveSW();
			}
		}
	}

}
